package com.shenchuangit.wma.ui.component;

import com.shenchuangit.wma.ui.UiConstants;

import javax.swing.*;
import java.awt.*;

/**
 * 左侧导航区域
 * @author dpf
 */
public class LeftNavLabel extends JLabel {
    private static final int NAV_HEIGHT = 40;

    private boolean activeFlag;

    private String targetPanelName;

    public LeftNavLabel(String text, int width, String targetPanelName) {
        this(text, width, targetPanelName, false);
    }

    public LeftNavLabel(String text, int width, String targetPanelName, boolean activeFlag) {
        this.setText(text);
        this.setPreferredSize(new Dimension(width, NAV_HEIGHT));
        this.setHorizontalAlignment(JLabel.CENTER);
        this.setVerticalAlignment(JLabel.CENTER);
        this.setFont(new Font(UiConstants.DEFAULT_FONT_FAMILY, Font.PLAIN, 14));

        this.targetPanelName = targetPanelName;

        this.active(activeFlag);
    }

    /**
     * 激活当前导航
     * @param activeFlag true：激活；false：反激活
     */
    public void active(boolean activeFlag) {
        this.activeFlag = activeFlag;
        if(activeFlag) {
            this.setBackground(UiConstants.COLOR_REVERSE);
            this.setOpaque(true);
            this.setForeground(UiConstants.COLOR_MAIN);
        } else {
            this.setBackground(UiConstants.COLOR_MAIN);
            this.setOpaque(true);
            this.setForeground(UiConstants.COLOR_REVERSE);
        }
    }

    public String getTargetPanelName() {
        return targetPanelName;
    }
}
